﻿$(function(){
    var util = CloudDisk.Util;
	
	
    CloudDisk.Workbench.init({
	    category: util.getUrlParameter('cid')
	});
    //implement a hash based navigation
	$(window).on('hashchange', function() {
        CloudDisk.Workbench.setPath(util.getUrlParameter('cid'), util.getUrlParameter('fid'));
    });
	
	
	//CloudDisk.DdUploader.init();
	CloudDisk.UploadMgr.init();
	
	//context menu for file list
	CloudDisk.FileContextMenu = new CloudDisk.ContextMenu({
		selector: '.list-view-item, .grid-view-item', //determine where to show the menu
		items: [{
			icon: '',
			title: '下载',
			handler: function(o){
			    alert('下载' + o.attr('itemId'));
			}
		}, '-', { // - represent a separator here
			icon: '',
			title: '分享',
			handler: function(o){}
		}, {
			icon: '',
			title: '删除',
			handler: function(o){}
		}] 
	});
	
	//menu showed when mouse over user's name
	CloudDisk.AccountMenu = new CloudDisk.ContextMenu({
		selector: '#username',
		items: [{
			icon: '',
			title: '个人资料',
			handler: function(){
			    alert('个人资料');
			}
		}, {
			icon: '',
			title: '帐户设置',
			handler: function(){}
		}, '-', {
			icon: '',
			title: '注销',
			handler: function(){}
		}] 
	});
	
	//window opened when doing share action 
	CloudDisk.ShareWindow = new CloudDisk.Window({
	    title: '分享',
		content: $('#shareWindowTpl').html(),
		height: 200
	});
});